<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">

            <div class="ibox-content">

                <div class="filter-box">

                    <form class="filter-form" id="filter-form">
                        <div class="div-box">
                            <div class="form-div">名称:
                                <label><input style="width: 120px" type="text" name="title"/></label>
                            </div>
                            <div class="form-div">类别名称:
                                <label><input style="width: 120px" type="text" name="catname"/></label>
                            </div>
                            <div class="form-div">
                                <div onclick="filterFun()" class="filter-submit btn btn-sm btn-primary">搜索</div>
                            </div>
                        </div>

                    </form>

                </div>

                <div class="jqGrid_wrapper">
                    <table id="table_list_1"></table>
                    <div id="pager_list_1"></div>
                </div>

            </div>
        </div>
    </div>

</div>


<!-- 自定义js -->
<script src="/static/js/content.js?v=1.0.0"></script>


<script>


    $(document).ready(function () {

        $.jgrid.defaults.styleUI = 'Bootstrap';
        // Examle data for jqGrid

        $("#table_list_1").jqGrid({
            datatype: "json", //将这里改为使用JSON数据
            url: 'index', //这是Action的请求地址
            mtype: 'POST',
            jsonReader: {
                root: "data.data",
                page: "data.current_page",
                total: "data.last_page",
                records: "data.total",
                repeatitems: true,
                id: "id"
            },
            // data: mydata,
            // datatype: "local",
            height: 550,
            autowidth: true,
            shrinkToFit: true,
            rowNum: 20,
            // rowList: [10, 20, 30],

            colNames: ['编号', '企业名称', '提现金额', '可用余额', '累计提现金额', '申请时间','状态', '操作'],
            colModel: [
                {name: 'id', index: 'id', width: 20},
                {name: 'company.company', index: 'company.company', width: 120},
                {name: 'number', index: 'number', width: 40},
                {name: 'user.cashing_money', index: 'user.cashing_money', width: 40},
                {name: 'user.cashed_money', index: 'user.cashed_money', width: 40},
                {name: 'create_time', index: 'create_time', width: 100},
                {
                    width: 100,
                    name: 'id',
                    formatter: function (value, grid, rows, state) {
                        //提现状态，0为发起提现待审核，1为审核通过，-1为审核不通过
                        switch (rows.status){
                            case 0:
                                return '待审核';
                                break;
                            case 1:
                                return '审核通过';
                                break;
                            case -1:
                                return '未通过';
                                break;
                        }

                    }
                },
                {
                    width: 100,
                    name: 'id',
                    formatter: function (value, grid, rows, state) {

                        var detailBtnStr = "<a class=\"btn btn-primary btn-sm m-r-sm\" href=\"apply?id=" + rows.id + "\">详情</a>",
                            delBtnStr = "<a class=\"btn btn-danger btn-sm m-r-sm\" href=\"destory?id=" + rows.id + "\">删除</a>";
                        return detailBtnStr+delBtnStr
                    }
                }
            ],
            pager: "#pager_list_1",
            viewrecords: true,
            hidegrid: false,

        });

        // Add selection
        $("#table_list_1").setSelection(4, true);


        // Setup buttons
        $("#table_list_1").jqGrid('navGrid', '#pager_list_1', {
            edit: false,
            add: false,
            addtext: '新增',
            addfunc: function () {

                location.href = '/mall/add';

            },
            del: false,
            search: false
        }, {
            height: 200,
            reloadAfterSubmit: true
        });

        // Add responsive to jqGrid
        $(window).bind('resize', function () {
            var width = $('.jqGrid_wrapper').width();
            $('#table_list_1').setGridWidth(width);
        });
    });


    function getSelecteds() {
//获取多选到的id集合
        var ids = $("#table_list_1").jqGrid("getGridParam", "selarrrow");
//遍历访问这个集合
        var tempArr = [];
        $(ids).each(function (index, id) {
            //由id获得对应数据行
            var row = $("#table_list_1").jqGrid('getRowData', id);

            tempArr.push({id: row.id, check: row.check})
        })

        return tempArr;
    }
</script>

<script>
    // filterFun()
    function filterFun() {

        var filterData = $('#filter-form').serializeArray()
        //传入查询条件参数
        $("#table_list_1").jqGrid("setGridParam", {postData: filterData}).trigger("reloadGrid");

    }
</script>

